#include<bits/stdc++.h>
using namespace std;
const int N=10010;
double vp[N][N];
bool bp[N];
int n,m,l,v,T,d[N],vc[N],a[N],p[N],cs,cx;
double vx(double vv,double aa,double xx)
{
    double k=sqrt(vv*vv+2*aa*xx);
    return k;
}
void csh()
{
    for(int j=1;j<=m;j++)
    {
        for(int i=1;i<=n;i++)
        {
            if(d[i]>l||p[j]>l) continue;
            double xx=double(p[j]-d[i]);
            double vxx=0;
            if(xx>=0)
            {
                if(a[i]==0) vxx=double(vc[i]);
                vxx=vx(double(vc[i]),double(a[i]),xx);
                vp[j][i]=vxx;
                if(vxx<=0) continue;
                if(vp[j][i]>v&&!bp[i])
                {
                    bp[i]=1;
                    cs++;
                }
            }
        }
    }
}
int main()
{

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        memset(vp,0,sizeof(vp));
        memset(bp,0,sizeof(bp));
        cs=0,cx=0;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>vc[i]>>a[i];
        for(int i=1;i<=m;i++)
            cin>>p[i];
        csh();
        for(int j=1;j<=m;j++)
        {
            bool b=0;
            for(int i=1;i<=n;i++)
            {
                if(vp[j][i]>v)
                {
                    b=1;
                    break;
                }
            }
            if(b==0) cx++;
        }
        cout<<cs<<" "<<cx<<endl;
    }
    return 0;
}
